package yyh.guanganmen.db;

import java.io.IOException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;


public class IdProvide {
	
	public List<String> getIds(String case_srccode) throws IOException{
		DbUtil db = new DbUtil();
		Connection conn = null;
		PreparedStatement ps = null;
		String sql = "";
		ResultSet rs = null;
		List<String> Ids = new ArrayList<String>();
	
		try{
			conn = db.getConnection();
			sql = "select distinct t.inhosptial_id from TBLZY_BASE t where t.case_srccode like '"+case_srccode+"%' ";
			ps = conn.prepareStatement(sql);
			rs = ps.executeQuery(sql);
			String id = new String();
			while(rs.next()){
				id = rs.getString("inhosptial_id");
				System.out.println(id);
				Ids.add(id);
			}
		}catch(SQLException e){
			e.printStackTrace();
		}finally{
			db.closeConn(conn, ps, rs);
		}
		//This is very important technology
		return Ids;
	}

//	public static void main(String[] args) throws IOException {
//		// TODO Auto-generated method stub
//		List<String> Ids = new IdProvide().getIds();
//		for(String id:Ids){
//			System.out.println(id);
//		}
//	}

}
